package com.yunbiao.ybbusstopplate.utils.core;

import android.content.Context;
import android.media.AudioManager;

import com.yunbiao.ybbusstopplate.base.APP;


public class SoundControl {

    public static Integer CURRENT_SOUND = 0;

    public static void setMusicSound(Double volume) {
        APP context = (APP) APP.Companion.getAppContext();
        if (context==null){
            return;
        }
        AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
        int max = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);//volume 0.0-1.0  volumD1-15
        Integer volumD = ((Double) (volume * max)).intValue();
        audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, volumD, AudioManager.FLAG_SHOW_UI | AudioManager.FLAG_PLAY_SOUND);

    }



}
